package demo.practice.leetcode_eveyday;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class P1436 {

    public String destCity(List<List<String>> paths) {
        if (paths.size() == 0)
            return null;

        String f = paths.get(0).get(0);
        Map<String, String> t = new HashMap<>();
        for (List<String> p : paths) {
            t.put(p.get(0), p.get(1));
        }
        while (t.get(f) != null)
            f = t.get(f);
        return f;
    }
}
